from django.db import models

# Create your models here.
    
class Course(models.Model):
    courseName = models.CharField(max_length = 100)
    postcode = models.CharField(max_length=8)
    def __unicode__(self):
        return self.courseName
    
class Golfer(models.Model):
    golferName = models.CharField(max_length=100)
    handicap = models.IntegerField()
    homeCourse = models.ForeignKey(Course) 
    def __unicode__(self):
        return self.golferName

class Scorecard(models.Model):
    golfer = models.ForeignKey(Golfer)
    date = models.DateField()
    course = models.ForeignKey(Course)
    def netTotal (self):
        return 72
    def __unicode__(self):
        return "{golfer} - {course} - {score}".format(golfer = self.golfer.golferName,
                                                      course = self.course.courseName,
                                                      score = self.netTotal())
    def golferName(self):
        return self.golfer.golferName
    def courseName(self):
        return self.course.courseName
            

class HoleScore(models.Model):
    scorecard = models.ForeignKey(Scorecard)
    holeNumber = models.IntegerField()
    net = models.IntegerField()
    